/*

Copyright (C) 2007 Thomas Geiger (tom.geiger@gmail.com)

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

*/


#ifndef GASSSERVER_H_
#define GASSSERVER_H_

#include <iostream>
#include <globus_common.h>
#include <globus_gass_server_ez.h>

using namespace std;

namespace globus_server {

/**
 * This class allows the control of a single threaded GASS server
 */
class GassServer
{
	public:
		/**
		 * Constructor
		 */
		GassServer();
		/**
		 * Destructor
		 */
		virtual ~GassServer();
		/**
		 * Start GASS server
		 * If no port has been specified, the server 
		 * listens at port 10001 by default
		 */
		bool start();
		/**
		 * Stop the server
		 */
		bool stop();
		/**
		 * Toogle security mode of GASS server
		 * If true is passed in, the server uses HTTPS
		 */
		bool setSecure(bool flag);
		/**
		 * Sets the port of the GASS server (0-65535)
		 */
		bool setPort(unsigned int port);
		/**
		 * Returns the port of the server
		 */
		unsigned int getPort();
		/**
		 * Returns true if server is running
		 */
		bool isRunning();
		/**
		 * Returns true if server is running in secure mode (HTTPS), 
		 * false otherwise
		 */
		bool isSecure();
	private:
		globus_gass_transfer_listenerattr_t attr;
		globus_gass_transfer_listener_t listener;
		unsigned int listenPort;
		unsigned long server_ez_opts;
		bool running;
		bool secure;
};

}

#endif /*GASSSERVER_H_*/
